<!DOCTYPE html>
<html lang="zh-CN" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head th:include="/common/inc::header"/>
<body>
<form class="layui-form">
    <input name="id" id="id" type="hidden"/>
    <br/>

    <div class="layui-form-item" style="margin-left: 20%">
        <label class="layui-form-label">交易凭证号</label>
        <div class="layui-input-inline" style="width: 350px">
            <input type="text" name="tradeNo" id="tradeNo" autocomplete="off" required
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" style="margin-left: 20%">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-inline" style="width: 350px">
            <input type="text" name="remark" id="remark" autocomplete="off" required
                   class="layui-input">
        </div>
    </div>
    <button class="layui-btn" id="formSubmit" lay-submit="" lay-filter="formSubmit" style="display: none">立即提交</button>
</form>
<script th:replace="/common/inc::incJs"></script>
<script>
    var form = layui.form;
    var successCallback;
    var id = getQueryString("id");
    $("#id").val(id);

    //监听提交
    form.on('submit(formSubmit)', function (data) {
        if ($("#tradeNo").val() == null) {
            layer.msg("请输入交易凭证号");
        } else {
            if (id != "") {
                $.post('/backend/security/withdrawBill/updateTradeNo', {
                    id: id,
                    tradeNo: $("#tradeNo").val()
                }, function (res) {
                    if (res.code < 0) {
                        layer.msg(res.message);
                    }
                    else {
                        layer.msg('操作成功');
                        parent.layui.table.reload("grid");
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    }
                });
            }
        }
        return false;
    });

    var formSubmit = function (callback) {
        successCallback = callback;
        $("#formSubmit").click();
    };


    $(function () {

    })
</script>
</body>
</html>
